Next | Prev | Up | Top | Contents | Index

Writing edtinit()

If you use the VECTOR: directive to configure a driver into the kernel, your driver can use a routine of the form drvedtinit(), where drv is the driver prefix. If your device driver object module includes a drvedtinit() routine, the system executes the drvedtinit() routine when the system boots. In general, you can use your drvedtinit() routine to perform any device driver initialization you want. Typically, the edtinit() routine is used to allocate and map in the resources that are needed for the driver to initialize the hardware and execute. The resources that might need to be initialized are:

When the system calls your driver's edtinit() routine, it hands the routine a pointer to a structure of type edt.

Synopsis

void drvedtinit(struct edt *e)
{
   your code here
}
The edt_t structure is filled in with the information taken from the system file when the operating system probes for the existence of the card. The edt_t structure is defined below.


edt_t Structure

The edt_t structure, defined in system/edt.h, contains resources specification information derived from the system file through the lboot operation.

Synopsis

#define NBASE 3
typedef unsigned long iopaddr_t;
typedef struct iospace {
    unchar       ios_type;       /* io space type on the adapter */
    iopaddr_t    ios_iopaddr;    /* io space base address */
    ulong        ios_size;
    caddr_t      ios_vaddr;      /* kernel virtual address */
} iospace_t;
typedef struct edt {
    uint_t       e_bus_type;    /* vme, scsi, eisa... */
    unchar       v_cpuintr;     /* cpu to send intr to */
    unchar       v_setcpuintr;  /* cpu field is valid */
    uint_t       e_adap;        /* adapter */
    uint_t       e_ctlr;        /* controller identifier */
    void*        e_bus_info;    /* bus dependent info */
    int          (*e_init)(struct edt *); /* device init/run-time probe */
    iospace_t    e_space[NBASE];
} edt_t;
Arguments

e_bus_type

Defined as EISA_ADAP as specified by bustype=EISA. This parameter is used in several other places, such as pio_mapalloc().

v_cpuintr

Currently unused. Reserved for future hardware use.

v_setcpuintr

Currently unused. Reserved for future hardware use.

e_adap

The Indigo2 is the only EISA-capable Silicon Graphics system, and it has only one EISA-bus slot, so e_adap is 0.

e_ctlr

This software specified device number is taken from the ctlr field of the system file VECTOR: line to differentiate more than one instance of the same device.

e_bus_info

This bus-dependent field is presently unused by EISA drivers. For bus type EISA_ADAP, it points to NULL.

e_init

Device initialization routine.

e_space

This array of iospace_t declarations tells the driver which
I/O and memory spaces the hardware is programmed to respond to.

Next | Prev | Up | Top | Contents | Index